package com.huoniu.api.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huoniu.api.entity.InspectItem;
import com.huoniu.api.mapper.InspectItemMapper;
import com.huoniu.common.core.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @类 名： InspectItemContoller <br/>
 * @描 述： <br/>
 * @日 期： 2020/9/11 10:12<br/>
 * @作 者： 侯建军<br/>
 * @版 本： 1.0.0
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/inspectItem")
public class InspectItemController {
    @Autowired
    private InspectItemMapper inspectItemMapper;

    @GetMapping
    public Result getInspectItems() {
        QueryWrapper queryWrapper = new QueryWrapper();
        List<InspectItem> inspectItemList = inspectItemMapper.selectList(queryWrapper);
        return Result.success(inspectItemList);
    }

    @PostMapping
    public Result insert(@RequestBody InspectItem inspectItem) {
        if (inspectItemMapper.insert(inspectItem) > 0) {
            return Result.success("添加成功");
        }
        return Result.fail("添加失败");
    }

}
